<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
    <meta charset="UTF-8">
    <title>银行管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
	    <form id="searchBar">
	        <div class="fieldset1 clearFix">
	            <div class="fieldBox">
	                <div class="label">银行名称</div>
	                <div class="field">
	                    <input name="bkNm" id="bkNm_S" type="text" class="ui-textbox" value="" >
	                </div>
	            </div>
	            <div class="fieldBox">
	                <div class="label">行号</div>
	                <div class="field">
	                    <input name="bkNo" id="bkNo_S" type="text" class="ui-textbox" value="">
	                </div>
	            </div>
	            <div class="clearFix"></div>
	            <div class="btnsBox">
	                <span id="searchBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
	                <span id="clearBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_19"></i>清空</span>
	                <!-- <span id="detailBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_2"></i>详细</span> -->
	                <span id="addBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_23"></i>新增总行</span>
	                <!-- <span id="changeBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_4"></i>修改</span>
	                <span id="delBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_7"></i>删除</span>
	                <span id="openBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_12"></i>启用</span>
	                <span id="closeBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_13"></i>禁用</span> -->
	                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
	        </div>
	    </form>
	</div>
	<div id="ligergrid1" class="sq-grid"></div>
</div>
<!-- 增加银行弹出框 -->
<div id="addBank_Html" style="display:none">
    <p class="dialogP" id="addBank_tip"><span class="c_red">若想添加支行，请先选择总行，再添加。</span></p>
    <form id="addBank_form">
        <div class="fieldset1 tabel_col tabel_col_1 clearFix">
            <div class="fieldBox col_100">
                <div class="label">类型</div>
                <div class="field">
                    <span id="addBankType_text">总行</span>
                    <input name="bkLvlCd" id="bkLvlCd" type="hidden" value="">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">银行名称</div>
                <div class="field">
                    <input name="bkNm" id="bkNm" type="text" class="ui-textbox" value="" validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">行号</div>
                <div class="field">
                    <input name="bkNo" id="bkNo" type="text" class="ui-textbox" value="" validate="{number:true}">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">地址</div>
                <div class="field">
                    <input name="bkAddr" id="bkAddr" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox col_100" id="bankOfheadQ">
                <div class="label">所属总行</div>
                <div class="field">
                    <span id="bankOfheadQ_text"></span>
                    <!-- <input name="bkPid" id="bkPid" type="hidden" value=""> -->
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">联系人</div>
                <div class="field">
                    <input name="lmNm" id="lmNm" type="text" class="ui-textbox" value="" validate="{nmcharacter:true}">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">联系电话</div>
                <div class="field">
                    <input name="lmTel" id="lmTel" type="text" class="ui-textbox" value="" validate="{mobileAndFixedPhone:true}">
                    <input id="resetBtn2" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span id="saveNewBank_Btn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_10"></i>保存</span>
        </div>
    </form>
</div>

<!-- 修改银行弹出框 -->
<div id="changeBank_Html" style="display:none">
    <form id="changeBank_form">
        <div class="fieldset1 tabel_col tabel_col_1 clearFix">
            <div class="fieldBox col_100">
                <div class="label">类型</div>
                <div class="field">
                    <input name="bkLvlNm" id="bkLvlNm2" type="text" readonly value="" style="border:1px;border-bottom-style:none;border-top-style:none;border-left-style:none;border-right-style:none;">
                    <input name="bkLvlCd" id="bkLvlCd2" type="hidden" value="">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">银行名称</div>
                <div class="field">
                    <input name="bkNm" id="bkNm2" type="text" class="ui-textbox" value="" validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">行号</div>
                <div class="field">
                    <input name="bkNo" id="bkNo2" type="text" class="ui-textbox" value="" validate="{number:true}">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">地址</div>
                <div class="field">
                    <input name="bkAddr" id="bkAddr2" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox col_100" id="bankOfheadQ2">
                <div class="label">所属总行</div>
                <div class="field">
                    <span id="bankOfheadQ2_text"></span>
                    <input name="bkPid" id="bkPid2" type="hidden" value="">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">联系人</div>
                <div class="field">
                    <input name="lmNm" id="lmNm2" type="text" class="ui-textbox" value="" validate="{nmcharacter:true}">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">联系电话</div>
                <div class="field">
                    <input name="lmTel" id="lmTel2" type="text" class="ui-textbox" value="" validate="{mobileAndFixedPhone:true}">
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span id="saveChangeBank_Btn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_10"></i>保存</span>
        </div>
    </form>
</div>

<script type="text/javascript">
var grid = null,
    menu = null;
var bankHeadQ = null;
var detailGrid = null;

var addBankData_s={
		bkLvlCd: null,
		bkPid:null,
       // bankHeadQ: null
    }
$(function () {
		grid = $("#ligergrid1").ligerGrid({
        url: '<%=path%>/system/sysBkInfo/initList.do',
        method : 'get',
        columns: [
			{ display: '银行名称', name: 'bkNm', minWidth: 150,align: 'left', enabledSort:true },
			{ display: '行号', name: 'bkNo', minWidth: 150, enabledSort:true},
			{ display: '类型', name: 'bkLvlNm', minWidth: 50 , enabledSort:true},
			{ display: '地址', name: 'bkAddr', minWidth: 200 , enabledSort:true},
			{ display: '状态', name: 'isOpen', minWidth: 100 , enabledSort:true},
			{ display: '联系人', name: 'lmNm', minWidth: 100 , enabledSort:true},
			{ display: '联系方式', name: 'lmTel', minWidth: 150 , enabledSort:true},
			{ display: '操作', width: 250 ,align:'left',
				render: function (rowdata, rowindex, value){
					var a = '<a class="sq-button-hasicon" href="javascript:;" onclick="addABtn(';
						a+="'"+rowdata.bkNm+"'";
						a+=",'"+rowdata.id+"'";
						a+=')"><i class="sqBtnIco_23"></i>新增支行</a>';
            		var v;
                    var v1='<a class="sq-button-hasicon" href="javascript:;" onclick="disable(';
                        v1+="'"+rowdata.id+"'";
                        v1+=')"><i class="sqBtnIco_13"></i>'+LogUtils.LOG_CMM_GRID_BTN_DISABLE+'</a>';
                        
                    var v2='<a class="sq-button-hasicon" href="javascript:;" onclick="enable(';
                        v2+="'"+rowdata.id+"'";
                        v2+=')"><i class="sqBtnIco_12"></i>'+LogUtils.LOG_CMM_GRID_BTN_ENABLE+'</a>';
                	switch (rowdata.isValid){
                       case 0:
                           v=v2;
                           break;
                       case 1:
                           v=v1;
                           break;
                       default:
                       	v=v1;
                       	break;
                    }
            		var h='<a class="sq-button-hasicon" href="javascript:toMfrModify(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')"><i class="sqBtnIco_4"></i>修改</a>';
            		var d='<a class="sq-button-hasicon" href="javascript:deleteRecord(';
	            		d+="'"+rowdata.id+"'";
	                    d+=')"><i class="sqBtnIco_7"></i>删除</a>';
                	return a + v + h + d;
            	}	
			},
        ],
        pageSize:10,
        root:'rows',
        record:'total',
        hideLoadButton : true,
        width: '100%',
        height: '100%',
        heightDiff: -2,
        //isScroll: false,
        //checkbox:true,  //显示checkbox
        // isSingleCheck: true,  //单选模式
        //rownumbers:true,  //显示序号
        allowUnSelectRow:true,
        alternatingRow: false,
        onAfterShowData: function () {
            grid.collapseAll();
            //SetIframe_height ();
        },
        onSelectRow: function (rowdata,rowNum,rowEl) {
        	$("#resetBtn2").click();//切换选择时清空弹出框数据
            // 选择父级 grid 的时候，取消子级的选中行
            var $detailPanels=$(rowEl).siblings('.l-grid-detailpanel');
            unselectGrid($detailPanels);
            bankHeadQ = getBankHeadQ(rowEl);
            if (parent && parent.pageInApp) {
                $.extend(true, parent.pageInApp, {seletedBankRow: rowdata});
            };
        },
        onUnSelectRow: function (rowdata) {
        	$("#resetBtn2").click();//切换选择时清空弹出框数据
            if (parent && parent.pageInApp) {
                $.extend(true, parent.pageInApp, {seletedBankRow: null});
            };
            bankHeadQ=null;
        },
        detail: {
            height: 'auto',
            onShowDetail: showDetail_grid
        },
        onDetailExtend: function () {
            SetIframe_height ();
        },
        onDetailCollapse: function () {
            SetIframe_height ();
        }
       
    });
		grid.setHeight(100);

    $("#searchBar").ligerForm();

    $("#pageloading").hide();
    
    $("#searchBtn").click(function(event) {
         var form = liger.get("searchBar");
         var data = form.getData();
         //alert(JSON.stringify(data));
         for (name in data){
            grid.setParm(name,data[name]);
         };
         bankHeadQ=null;
		$("#resetBtn2").click();
		parent.pageInApp.seletedBankRow=null;
        grid.reload();
    });
    $("#clearBtn").click(function(event) {
        $("#resetBtn").click();  //重置 input-text
    });
    
    $("#addBtn").click(function(event) {
        $.ligerDialog.open({
            width: 400,
            //top: 100,
            title : '新增总行',
            target: $("#addBank_Html"),
            onHideDialog: function () {
                clearLigerForm("addBank_form");
            }
        });
        var ligerForm = $("#addBank_form").ligerForm({validate: true});
        //var bankHeadQ = getBankHeadQ();
      
            $("#addBank_tip").hide();
	        $("#addBankType_text").text("总行");
	        $("#bankOfheadQ").hide();
	        $("#bankOfheadQ_text").text("");
	        addBankData_s.bkPid ="";
	        addBankData_s.bkLvlCd = 1;//级别
        
    });
    $("#saveNewBank_Btn").click(function(event) {
        var form = liger.get("addBank_form");
        if (!form.valid()) {
        	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var data = form.getData();
        $.extend(true, data, addBankData_s); //合并要添加的银行类型和总行pid
        //alert("--- 验证通过！可以提交 ---\n" + JSON.stringify(data));
        $.ligerDialog.hide();
		//以下应该有一段Ajax交互
		var wait_dialog;
		$.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: '<%=path%>/system/sysBkInfo/add.do',
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			},
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					bankHeadQ=null;
					$("#resetBtn").click();
					$("#resetBtn2").click();
					 parent.pageInApp.seletedBankRow=null;
					 $("#searchBtn").click();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
    });
    
   /* 修改银行信息 */
    <%-- $("#changeBtn").click(function(event) {
    	var selectedRows = grid.getSelectedRows();
    	var id = null;
		if(selectedRows.length != 1){
			selectedRows = parent.pageInApp.seletedBankRow;
			if(!selectedRows){
				$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
				return;
			}
			id = selectedRows.id;
		}else{
			id = selectedRows[0].id;
		}
		
    	$.ajax({
			type: 'get',
			dataType:'json',
			data:{id:id},
			url: '<%=path%>/system/sysBkInfo/getById.do',
			success:function(msg){
				if(msg.success == 1){
					//$.ligerDialog.success(msg.info)
					openChange();//弹出修改框
					setData(msg.data);//设置数据
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
    	
    }); --%>
    $("#saveChangeBank_Btn").click(function(event) {
        var form = liger.get("changeBank_form");
        if (!form.valid()) {
        	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var data = form.getData();
        $.extend(true, data, addBankData_s); //合并要修改的银行信息(主键id)
        //alert("--- 验证通过！可以提交 ---\n" + JSON.stringify(data));
        $.ligerDialog.hide();
		//以下应该有一段Ajax交互
		var wait_dialog;
		$.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: '<%=path%>/system/sysBkInfo/modify.do',
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			},
			success:function(msg){
				wait_dialog.close();
				debugger;
				if(msg.success == 1){
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 bankHeadQ=null;
					 $("#resetBtn").click();
					 $("#resetBtn2").click();
					 parent.pageInApp.seletedBankRow=null;
					 $("#searchBtn").click();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
				
				 
			}
		});
    });
    
    //查询账号
    $("#searchAccBtn").click(function(){
    	var row = grid.getSelectedRow();
    	var _id;
    	if(row){
    		_id = row.id;
			parent.mainApp.f_addTab('Bk_1','查询银行账号','<%=path%>/system/sysBkAccInfo/toListPage.do?bkId='+_id);
    	}else{
    		parent.mainApp.f_addTab('Bk_1','查询银行账号','<%=path%>/system/sysBkAccInfo/toListPage.do');
    	}
    });
  //启用
    <%-- $("#openBtn").click(function(){
		var selectedRows = grid.getSelectedRows();
		var id = null;
		if(selectedRows.length != 1){
			selectedRows = parent.pageInApp.seletedBankRow;
			if(!selectedRows){
				$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
				return;
			}
			var _val = selectedRows.isOpen;
		   	 if(_val==LogUtils.LOG_CMM_GRID_BTN_ENABLE){
		   		$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_ENABLED_STATUS, SQ_type: "warning"});
	   			return;
		   	 }
			id = selectedRows.id;
		}else{
			var _val = selectedRows[0].isOpen;
		   	 if(_val==LogUtils.LOG_CMM_GRID_BTN_ENABLE){
		   		$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_ENABLED_STATUS, SQ_type: "warning"});
	   			return;
		   	 }
			id = selectedRows[0].id;
		}
   		alert(id);
   		$.ligerDialog.confirm(LogUtils.LOG_CMM_ENABLE_CONFIRM, function (flag) {
   			if(flag == false)return;
   			$.ajax({
   				type: 'post',
   				dataType:'json',
   				data:{id:JSON.stringify(id)},
   				url: '<%=path%>/system/sysBkInfo/enable.do',
   				success:function(msg){
   					 if(msg.success == 1){
   						$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
   						bankHeadQ=null;
   						parent.pageInApp.seletedBankRow=null;
   						 grid.reload();
   					 }else{
   						$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
   					 }
   				}
   			});
   		});
    }); --%>
  //禁用
    <%-- $("#closeBtn").click(function(){
    	var selectedRows = grid.getSelectedRows();
		var id = null;
		if(selectedRows.length != 1){
			selectedRows = parent.pageInApp.seletedBankRow;
			if(!selectedRows){
				$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
				return;
			}
			var _val = selectedRows.isOpen;
		   	 if(_val==LogUtils.LOG_CMM_GRID_BTN_DISABLE){
		   		$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_DISABLED_STATUS, SQ_type: "warning"});
	   			return;
		   	 }
			id = selectedRows.id;
		}else{
			var _val = selectedRows[0].isOpen;
		   	 if(_val==LogUtils.LOG_CMM_GRID_BTN_DISABLE){
		   		$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_DISABLED_STATUS, SQ_type: "warning"});
	   			return;
		   	 }
			id = selectedRows[0].id;
		}
   		
   		$.ligerDialog.confirm(LogUtils.LOG_CMM_DISABLE_CONFIRM, function (flag) {
   			if(flag == false)return;
   			$.ajax({
   				type: 'post',
   				dataType:'json',
   				data:{id:JSON.stringify(id)},
   				url: '<%=path%>/system/sysBkInfo/disable.do',
   				success:function(msg){
   					 if(msg.success == 1){
   						$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
   						bankHeadQ=null;
   						parent.pageInApp.seletedBankRow=null;
   						 grid.reload();
   					 }else{
   						$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
   					 }
   				}
   			});
   		});
    });  --%>
  
  	//var detailGrid = null;
    function showDetail_grid(row, detailPanel, callback){
        var gridBox = document.createElement('div');
            
        $(gridBox).css('margin', 10);
        if((!row.children) || (row.children.length == 0)){
            console.log(row.children);
            $(gridBox).append('<div class="TC">没有支行</div>');
            $(detailPanel).append(gridBox);
            return false;
        };
        //$(detailPanel).append(gridBox);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        detailGrid = $(gridBox).ligerGrid({
            columns: [
				{ display: '银行名称', name: 'bkNm', minWidth: 150,align: 'left', enabledSort:true },
				{ display: '行号', name: 'bkNo', minWidth: 150, enabledSort:true},
				{ display: '类型', name: 'bkLvlNm', minWidth: 50 , enabledSort:true},
				{ display: '地址', name: 'bkAddr', minWidth: 200 , enabledSort:true},
				{ display: '状态', name: 'isOpen', minWidth: 100 , enabledSort:true},
				{ display: '联系人', name: 'lmNm', minWidth: 100 , enabledSort:true},
				{ display: '联系方式', name: 'lmTel', minWidth: 150 , enabledSort:true},
				{ display: '操作', width: 200 ,align:'left',
					render: function (rowdata, rowindex, value){
	            		var v;
	                    var v1='<a class="sq-button-hasicon" href="javascript:;" onclick="disable(';
	                        v1+="'"+rowdata.id+"'";
	                        v1+=')"><i class="sqBtnIco_13"></i>'+LogUtils.LOG_CMM_GRID_BTN_DISABLE+'</a>';
	                        
	                    var v2='<a class="sq-button-hasicon" href="javascript:;" onclick="enable(';
	                        v2+="'"+rowdata.id+"'";
	                        v2+=')"><i class="sqBtnIco_12"></i>'+LogUtils.LOG_CMM_GRID_BTN_ENABLE+'</a>';
	                	switch (rowdata.isValid){
	                       case 0:
	                           v=v2;
	                           break;
	                       case 1:
	                           v=v1;
	                           break;
	                       default:
	                       	v=v1;
	                       	break;
	                    }
	            		var h='<a class="sq-button-hasicon" href="javascript:toMfrModify(';
		            		h+="'"+rowdata.id+"'";
		                    h+=')"><i class="sqBtnIco_4"></i>修改</a>';
	            		var d='<a class="sq-button-hasicon" href="javascript:deleteRecord(';
		            		d+="'"+rowdata.id+"'";
		                    d+=')"><i class="sqBtnIco_7"></i>删除</a>';
	                	return v + h + d;
	            	}	
				},
            ],
            data: {Rows: row.children},
            pageSize:10,
            hideLoadButton : true,
            width: '100%',
            isScroll: false,
            rownumbers:true,  //显示序号
            allowUnSelectRow:true,
            alternatingRow: false,
           	onAfterShowData: callback,
            //onAfterShowData: SetIframe_height,
            frozen: false,
            usePager: false,
            onSelectRow: function (rowdata,rowNum,rowEl) {
            	$("#resetBtn2").click();//切换选择时清空弹出框数据
                // 选择子级 grid 的时候，取消父级的选中行 & 其它子级的选中行
                var selectedRow_4parent = grid.getSelectedRow();
                if (selectedRow_4parent) grid.unselect(selectedRow_4parent);
                var $detailPanels=$(rowEl).parents('.l-grid-detailpanel').siblings('.l-grid-detailpanel');
                unselectGrid($detailPanels);
				
                bankHeadQ = getBankHeadQ(rowEl);
                console.log(bankHeadQ);
                //alert(JSON.stringify(bankHeadQ));
                
                if (parent && parent.pageInApp) {
                    $.extend(true, parent.pageInApp, {seletedBankRow: rowdata});
                };
            },
            onUnSelectRow: function (rowdata) {
            	$("#resetBtn2").click();//切换选择时清空弹出框数据
                if (parent && parent.pageInApp) {
                    $.extend(true, parent.pageInApp, {seletedBankRow: null});
                };
                bankHeadQ=null;
            }
        });
    }
    function getBankHeadQ(rowEl){
        var selectedRowId = $(rowEl).parents('.l-grid-detailpanel').attr('id');
        var selectedRowId_4Parent = null;
        if (selectedRowId) {
            selectedRowId_4Parent = selectedRowId.slice(selectedRowId.lastIndexOf("|")+1)
            bankHeadQ = grid.getRow(selectedRowId_4Parent);
        }else{
            bankHeadQ = grid.getSelectedRow();
        };
        return bankHeadQ;
    }
    function unselectGrid (gridPanels) {
        gridPanels.each(function(index, el) {
            var detailGrid_Id=$(this).find('.l-panel').attr('ligeruiid');
            if (detailGrid_Id) {
                var detail_grid = liger.get(detailGrid_Id);
                var selectedRow_4DetailGrid = detail_grid.getSelectedRow();
                if (selectedRow_4DetailGrid) detail_grid.unselect(selectedRow_4DetailGrid);
            }
        });
    }
  
  
    
});
//启用
function enable(id){
	if(!id)return;
	$.ligerDialog.confirm(LogUtils.LOG_CMM_ENABLE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:id},
				url: '<%=path%>/system/sysBkInfo/enable.do',
				success:function(msg){
					 if(msg.success == 1){
						$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
}
//禁用
function disable(id){
	if(!id)return;
	$.ligerDialog.confirm(LogUtils.LOG_CMM_DISABLE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:id},
				url: '<%=path%>/system/sysBkInfo/disable.do',
				success:function(msg){
					 if(msg.success == 1){
						$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
}
//修改
function toMfrModify(id){
	if(!id)return;
	$.ajax({
		type: 'get',
		dataType:'json',
		data:{id:id},
		url: '<%=path%>/system/sysBkInfo/getById.do',
		success:function(msg){
			if(msg.success == 1){
				//$.ligerDialog.success(msg.info)
				openChange();//弹出修改框
				setData(msg.data);//设置数据
			 }else{
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}
//新增支行
function addABtn(_bkNm,_id){
	$.ligerDialog.open({
        width: 400,
        //top: 100,
        title : '新增支行',
        target: $("#addBank_Html"),
        onHideDialog: function () {
            clearLigerForm("addBank_form");
        }
    });
    var ligerForm = $("#addBank_form").ligerForm({validate: true});
    //var bankHeadQ = getBankHeadQ();
        $("#addBank_tip").hide();
        $("#addBankType_text").text("支行");
        $("#bankOfheadQ").show();
        $("#bankOfheadQ_text").text(_bkNm);
        addBankData_s.bkPid = _id;//总行id
        addBankData_s.bkLvlCd = 2;//级别
}
//设置页面数据
function setData(data){
	//alert("setdate...");
	var form = new liger.get("changeBank_form");
	addBankData_s.id=data.id;
	form.setData({
		bkLvlNm:data.bkLvlNm,
		bkLvlCd:data.bkLvlCd,
		bkNm:data.bkNm,
		bkNo:data.bkNo,
		bkAddr:data.bkAddr,
		bkPid:data.bkPid,
		lmNm:data.lmNm,
		lmTel:data.lmTel
	});
} 

function openChange(){
	//alert("openchange...");
	$.ligerDialog.open({
        width: 400,
        top: 100,
        title : '修改银行信息',
        target: $("#changeBank_Html"),
        onHideDialog: function () {
            clearLigerForm("changeBank_form");
        }
    });
	
	$("#changeBank_form").ligerForm({validate: true});
	var selectedBank = grid.getSelectedRow();
	if(selectedBank){
			$("#bankOfheadQ2").hide();
			addBankData_s.bkPid ="";
            addBankData_s.bkLvlCd = 1;//级别
	}else{
		selectedBank = parent.pageInApp.seletedBankRow;
		if(selectedBank){
			$("#bankOfheadQ2").show();
	        $("#bankOfheadQ2_text").text(bankHeadQ.bkNm);
	        addBankData_s.bkPid = bankHeadQ.id;//总行id
            addBankData_s.bkLvlCd = 2;//级别
		}
	}
    
}


function iframeResize_pageIn () {
    if (parent.pageInApp) {
        parent.pageInApp.pageInTab.onResize();
        iframeResize ()
    };
}
function iframeResize () {
    if (parent.parent.mainApp) {
        parent.parent.mainApp.parentTab.onResize();
    };
}
//删除数据
function deleteRecord(id){
	var _ids = [];
	if(!id){
		return;
	}else{
		_ids.push(id);
	}
	/* for ( var index in selectedRows) {
		_ids.push(selectedRows[index].id);
	} */
	$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM+'此操作将会级联删除该银行下所有账户!', function (flag) {
		if(flag == false)return;
		var wait_dialog;
		$.ajax({
			type: 'post',
			dataType:'json',
			data:{ids:JSON.stringify(_ids)},
			url: '<%=path%>/system/sysBkInfo/removeByIds.do',
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				wait_dialog.close();
				 if(msg.success == 1){
					 bankHeadQ=null;
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 parent.pageInApp.seletedBankRow=null;
					 grid.reload();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	});
}
if(!SetIframe_height){
	var SetIframe_height = function () {
	    if (parent && parent.mainApp && parent.mainApp.parentTab && parent.mainApp.parentTab.onResize) {
	        parent.mainApp.parentTab.onResize();
	    }else
	    if (parent && parent.pageInApp && parent.pageInApp.pageInTab && parent.pageInApp.pageInTab.onResize) {
	        parent.pageInApp.pageInTab.onResize();
	        // parent.parent.mainApp.parentTab.onResize();
	    };
	}
}
</script>

</body>
</html>
